package org.chen.spring.cloud.finchley.zuul;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.Enumeration;

/**
 * @author chensj
 * @date 2020-02-11 21:19
 */
@SpringBootApplication
@RestController
@EnableDiscoveryClient
@EnableZuulProxy
public class ZuulServerApplication {

    public static void main(String[] args) {
        SpringApplication.run(ZuulServerApplication.class, args);
    }

    @RequestMapping(value = "/")
    public String test(HttpServletRequest request) {
        System.out.println("--------------header-----------------");
        Enumeration<String> headerNames = request.getHeaderNames();
        while (headerNames.hasMoreElements()) {
            String key = (String) headerNames.nextElement();
            System.out.println("Header key:" + key + " : " + request.getHeader(key));
        }
        System.out.println("--------------header-----------------");
        return "Hellooooooooooooooooooooooooooooooo!";
    }
}
